package me.yuxiaoyao.example.lock.controller;

import me.yuxiaoyao.example.lock.service.TestService;
import me.yuxiaoyao.lock.annotation.DistributedLock;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author kerryzhang on 2020/12/23
 */

@RequestMapping("/service")
@RestController
public class ServiceController {

    private final TestService testService;

    public ServiceController(TestService testService) {
        this.testService = testService;
    }

    @GetMapping("/param/{id}")
    public Object param(@PathVariable("id") Long id) throws InterruptedException {
        return testService.param(id);
    }

    @GetMapping("/method")
    public Object method() throws InterruptedException {
        return testService.method();
    }


    @GetMapping("/constKey")
    public Object constKey() throws InterruptedException {
        return testService.constKey();
    }


    @GetMapping("/mixParam/{id}")
    public Object mixParam(@PathVariable("id") Long id) throws InterruptedException {
        return testService.mixParam(id);
    }

}
